<!DOCTYPE html>
<html>
<head>
<title>Test that CSS selector queries on duplicate Ids respect scope.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
    <span id="duplicateId1"></span>
    <span id="duplicateId1"></span>
    <span id="duplicateId2"></span>
    <span id="duplicateId2"></span>
    <div id="scopeDiv">
        <span id="duplicateId1"></span>
        <span id="duplicateId1"></span>
        <span id="duplicateId1"></span>
        <span id="duplicateId1"></span>
    </div>
    <script>
      setup({ single_test: true });

      assert_equals(document.querySelectorAll('#duplicateId1').length, 6);
      assert_equals(document.querySelectorAll('#duplicateId2').length, 2);

      scopeDiv = document.getElementById("scopeDiv");
      assert_equals(scopeDiv.querySelectorAll('#duplicateId1').length, 4);
      assert_equals(scopeDiv.querySelector('#duplicateId2'), null);
      assert_equals(scopeDiv.querySelectorAll('#duplicateId2').length, 0);
      done();
</script>
</body>
</html>
